<!DOCTYPE html>
<html>
  <head>
    <title>登录</title>
    <%- include('../head') %>

    <style>
      h1{
        text-align: center;
        font-size: 30px;
        font-weight: bold;
        padding-bottom: 10px;
      }
      p{
        text-align: center;
        padding-top: 10px;
      }
      input{
        width: 260px;
        height:26px;
      }
      button{
        width: 80px;
        height: 26px;
      }
    </style>
  </head>
  <body>
    <h1>登录</h1>
    <p>
    	用户名: <input type="text" name="username" id="username" value="" />
    </p>
    <p>
    	密<em style="padding-left: 1em;"></em>码: <input type="text" name="password" id="password" value="" />
    </p>
    <p>
    	<button class="btn">登录</button>

    </p>
    <p style="display: none">
        备案号： 42011502000292
    </p>
  </body>

  <script type="text/javascript">
  	
	$(".btn").on("click",function(){
		var name = $("#username").val().trim();
		var pwd = $("#password").val().trim();
      if(!name || !pwd){
        alert("用户名或密码不能为空");
        return ;
      }
		$.ajax({
			type:"post",
			url:"/api/user/login",
			data:{
				name:name,
				password:pwd
			},
			success:function(data){
			  console.log(data);
              window.location.href = '/';

			},
			error:function(error){
				console.log(error);
			}
		});
	});
  </script>
</html>
